//
//  CNKISearchViewController.h
//  CNKICommunity
//
//  Created by wei on 17/3/13.
//  Copyright © 2017年 CNKI. All rights reserved.
//

#import <UIKit/UIKit.h>





@class CNKISearchViewController;

@protocol CNKISearchVCdelegate <NSObject>

@optional

//用于获取搜索建议
-(void)searchVC:(CNKISearchViewController*)vc searchTextDidChange:(UISearchBar*)bar searchText:(NSString*)searchText;

@end


typedef NS_ENUM(NSInteger,CNKISearchHistoryStyle)
{
    CNKISearchHistoryStyleCell
};


//搜索开始时调用的block
typedef void(^CNKISearchBlock)(CNKISearchViewController *searchVC,UISearchBar *searchBar,NSString *searchText);

@interface CNKISearchViewController : UIViewController


@property(nonatomic,weak)UIView *HotsearchHeadView;//热门搜索头部内容
@property(nonatomic,weak)UILabel *HotsearchLabel;//热门搜索标题

@property(nonatomic,weak)UIView *HotsearchHeadTagView;//热门搜索的标签内容
@property(nonatomic,weak)UISearchBar *searchBar;//搜索框
@property(nonatomic,copy)NSArray *hotSearchArr;//热门搜索数组
@property(nonatomic,copy)CNKISearchBlock DidSearchBlock;//点击搜索后的block回调
@property(nonatomic,weak)UIButton *clearBtn;//清除按钮

@property(nonatomic,strong)NSString *searchHistoryCachesPath;//搜索历史缓存路径
@property(nonatomic,assign)NSInteger searchHistoryNum;//搜索历史缓存的默认数目

@property(nonatomic,assign)CNKISearchHistoryStyle CNKIBottomSearchHistoryStyle;//搜索历史风格

@property(nonatomic,assign)BOOL showSearchSuggestWhenSearchTextChanged;//搜索文本改变时是否显示搜索建议
@property(nonatomic,assign)BOOL showSearchResultWhenSearchTextFocused;//搜索框聚焦时是否显示搜索结果
@property(nonatomic,strong)NSArray <NSString *> *searchSuggestions;//搜索建议数组
@property(nonatomic,weak)id <CNKISearchVCdelegate> SearchDelegate;


//创建搜索器
+(CNKISearchViewController*)setupSearchVCWithHotSearches:(NSArray<NSString *> *)HotSearches searchPlaceholder:(NSString*)placeHolder;

//创建搜索控制器的方法 带block
+(CNKISearchViewController*)setupSearchVCWithHotSearches:(NSArray<NSString *> *)HotSearches searchPlaceholder:(NSString*)placeHolder Searchblock:(CNKISearchBlock)searchblock;



@end
